package com.nf.recruitment.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageInfo;
import com.nf.recruitment.dao.CandidateMapper;
import com.nf.recruitment.dto.CandidateDTO;
import com.nf.recruitment.dto.CandidatePageDTO;
import com.nf.recruitment.dto.CandidateStatusDTO;
import com.nf.recruitment.entity.*;
import com.nf.recruitment.service.CandidateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CandidateServiceImpl implements CandidateService {
    @Autowired
    private CandidateMapper candidateMapper;

    @Override
    public CandidatePageDTO listCandidate(int pageNum, int pageSize, int post, int degree) {
        List<CandidateDTO> list = candidateMapper.listCandidate(pageNum, pageSize, post, degree);
        PageInfo<CandidateDTO> candidate = new PageInfo<>(list);
        CandidatePageDTO pageDTO = BeanUtil.copyProperties(candidate, CandidatePageDTO.class);
        return pageDTO;
    }

    @Override
    public void saveCandidate(Candidate candidate) {
        candidateMapper.saveCandidate(candidate);
    }

    @Override
    public void changeStatus(CandidateStatusDTO candidateStatus) {
        candidateMapper.changeStatus(candidateStatus);
    }
}
